

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>aiy.assistant &mdash; AIY Projects 2018-11-16 documentation</title>
  

  
  
  
  

  
  <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script src="_static/jquery.js"></script>
        <script src="_static/underscore.js"></script>
        <script src="_static/doctools.js"></script>
        <script src="_static/language_data.js"></script>
    
    <script type="text/javascript" src="_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="_static/custom.css" type="text/css" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="aiy.cloudspeech" href="aiy.cloudspeech.html" />
    <link rel="prev" title="Voice Kit overview" href="voice.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="index.html" class="icon icon-home"> AIY Projects
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Common APIs</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="aiy.board.html">aiy.board</a></li>
<li class="toctree-l1"><a class="reference internal" href="aiy.leds.html">aiy.leds</a></li>
<li class="toctree-l1"><a class="reference internal" href="aiy.pins.html">aiy.pins</a></li>
</ul>
<p class="caption"><span class="caption-text">Vision Kit APIs</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="vision.html">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="aiy.toneplayer.html">aiy.toneplayer</a></li>
<li class="toctree-l1"><a class="reference internal" href="aiy.trackplayer.html">aiy.trackplayer</a></li>
<li class="toctree-l1"><a class="reference internal" href="aiy.vision.annotator.html">aiy.vision.annotator</a></li>
<li class="toctree-l1"><a class="reference internal" href="aiy.vision.inference.html">aiy.vision.inference</a></li>
<li class="toctree-l1"><a class="reference internal" href="aiy.vision.models.html">aiy.vision.models</a></li>
</ul>
<p class="caption"><span class="caption-text">Voice Kit APIs</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="voice.html">Overview</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">aiy.assistant</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#module-aiy.assistant.grpc">aiy.assistant.grpc</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-aiy.assistant.library">aiy.assistant.library</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-aiy.assistant.auth_helpers">aiy.assistant.auth_helpers</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="aiy.cloudspeech.html">aiy.cloudspeech</a></li>
<li class="toctree-l1"><a class="reference internal" href="aiy.voice.audio.html">aiy.voice.audio</a></li>
<li class="toctree-l1"><a class="reference internal" href="aiy.voice.tts.html">aiy.voice.tts</a></li>
</ul>
<p class="caption"><span class="caption-text">Other docs</span></p>
<ul>
<li class="toctree-l1"><a class="reference external" href="https://github.com/google/aiyprojects-raspbian">Source code (GitHub)</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/google/aiyprojects-raspbian/blob/aiyprojects/CHANGES.md">Change log (GitHub)</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/google/aiyprojects-raspbian/blob/aiyprojects/HACKING.md">Software setup (GitHub)</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/google/aiyprojects-raspbian/blob/aiyprojects/CONTRIBUTING.md">Contribution guide (GitHub)</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">AIY Projects</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html">Docs</a> &raquo;</li>
        
      <li>aiy.assistant</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="_sources/aiy.assistant.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="aiy-assistant">
<h1>aiy.assistant<a class="headerlink" href="#aiy-assistant" title="Permalink to this headline">¶</a></h1>
<p>APIs that simplify interaction with the
<a class="reference external" href="https://developers.google.com/assistant/sdk/">Google Assistant API</a> in one of two ways:
using either <a class="reference internal" href="#module-aiy.assistant.grpc" title="aiy.assistant.grpc"><code class="xref py py-mod docutils literal notranslate"><span class="pre">aiy.assistant.grpc</span></code></a> or <a class="reference internal" href="#module-aiy.assistant.library" title="aiy.assistant.library"><code class="xref py py-mod docutils literal notranslate"><span class="pre">aiy.assistant.library</span></code></a>, corresponding to the
<a class="reference external" href="https://developers.google.com/assistant/sdk/guides/service/python/">Google Assistant Service</a> and <a class="reference external" href="https://developers.google.com/assistant/sdk/guides/library/python/">Google Assistant Library</a>, respectively.</p>
<p>Which of these you choose may depend on your intentions.
The Google Assistant Service provides a gRPC interface that is generally more complicated. However,
the <a class="reference internal" href="#module-aiy.assistant.grpc" title="aiy.assistant.grpc"><code class="xref py py-mod docutils literal notranslate"><span class="pre">aiy.assistant.grpc</span></code></a> API offered here does not provide access to those APIs. Instead, it
completely wraps the <code> <a class="reference external" href="https://developers.google.com/assistant/sdk/reference/rpc/#google.assistant.embedded.v1alpha2">google.assistant.embedded.v1alpha2</a></code> APIs. It
takes care of all the complicated setup for you, and handles all response events. Thus, if all you
want to build a basic version of the Google Assistant, then using <a class="reference internal" href="#module-aiy.assistant.grpc" title="aiy.assistant.grpc"><code class="xref py py-mod docutils literal notranslate"><span class="pre">aiy.assistant.grpc</span></code></a>
is easiest because it requires the least amount of code.
For an example, see <a class="reference external" href="https://github.com/google/aiyprojects-raspbian/tree/aiyprojects/src/examples/voice/assistant_grpc_demo.py">src/examples/voice/assistant_grpc_demo.py</a>.</p>
<p>On the other hand, <a class="reference internal" href="#module-aiy.assistant.library" title="aiy.assistant.library"><code class="xref py py-mod docutils literal notranslate"><span class="pre">aiy.assistant.library</span></code></a> is a thin wrapper around
<code> <a class="reference external" href="https://developers.google.com/assistant/sdk/reference/library/python/#">google.assistant.library</a></code>. It overrides the <code class="docutils literal notranslate"><span class="pre">Assistant.start()</span></code>
method to handle the device registration, but beyond that, you can and must use the
<code> <a class="reference external" href="https://developers.google.com/assistant/sdk/reference/library/python/#">google.assistant.library</a></code> APIs to respond to all events returned by
the Google Assistant. As such, using <a class="reference internal" href="#module-aiy.assistant.library" title="aiy.assistant.library"><code class="xref py py-mod docutils literal notranslate"><span class="pre">aiy.assistant.library</span></code></a> provides you more control,
allowing you to build custom device commands based on conversation with the Google Assistant.
For an example, see <a class="reference external" href="https://github.com/google/aiyprojects-raspbian/tree/aiyprojects/src/examples/voice/assistant_library_with_local_commands_demo.py">src/examples/voice/assistant_library_with_local_commands_demo.py</a>.</p>
<p>Additionally, only <a class="reference internal" href="#module-aiy.assistant.library" title="aiy.assistant.library"><code class="xref py py-mod docutils literal notranslate"><span class="pre">aiy.assistant.library</span></code></a> includes built-in support for hotword detection
(such as “Okay Google”). However, if you’re using the Raspberry Pi Zero (provided with the V2 Voice
Kit), then you cannot use hotword detection because that feature depends on the ARMv7 architecture
and the Pi Zero has only ARMv6. So that feature of the library works only with Raspberry Pi 2/3,
and if you’re using a Pi Zero, you must instead use the button or another type of trigger to
initiate a conversation with the Google Assistant. (Note: The Voice Bonnet can be used on
any Raspberry Pi.)</p>
<p><strong>Tip:</strong> If all you want to do is create custom voice commands (such as “turn on the light”), then
you don’t need to interact with the Google Assistant. Instead, you can use <a class="reference internal" href="aiy.cloudspeech.html#module-aiy.cloudspeech" title="aiy.cloudspeech"><code class="xref py py-mod docutils literal notranslate"><span class="pre">aiy.cloudspeech</span></code></a>
to convert your voice commands into text that triggers your actions.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>These APIs are designed for the Voice Kit, but have no dependency on the Voice
HAT/Bonnet specifically. However, they do require some type of sound card
attached to the Raspberry Pi that can be detected by the ALSA subsystem.</p>
</div>
<div class="section" id="module-aiy.assistant.grpc">
<span id="aiy-assistant-grpc"></span><h2>aiy.assistant.grpc<a class="headerlink" href="#module-aiy.assistant.grpc" title="Permalink to this headline">¶</a></h2>
<p>Enables a conversation with the Google Assistant, using the <a class="reference external" href="https://developers.google.com/assistant/sdk/guides/service/python/">Google Assistant Service</a>, which
connects to the Google Assistant using a streaming endpoint over gRPC.</p>
<p>This gRPC service is typically more complicated to set up, compared to the Google Assistant
Library, but this API takes care of all the complexity for you. So you simply create an instance
of <a class="reference internal" href="#aiy.assistant.grpc.AssistantServiceClient" title="aiy.assistant.grpc.AssistantServiceClient"><code class="xref py py-class docutils literal notranslate"><span class="pre">AssistantServiceClient</span></code></a>, then start the Google Assistant by calling
<a class="reference internal" href="#aiy.assistant.grpc.AssistantServiceClient.conversation" title="aiy.assistant.grpc.AssistantServiceClient.conversation"><code class="xref py py-meth docutils literal notranslate"><span class="pre">conversation()</span></code></a>.</p>
<p>This API provides only an interface to initiate a conversation with the Google Assistant. It
speaks and prints all responses for you—it does not allow you to handle the response events or
create custom commands.
For an example, see <a class="reference external" href="https://github.com/google/aiyprojects-raspbian/tree/aiyprojects/src/examples/voice/assistant_grpc_demo.py">src/examples/voice/assistant_grpc_demo.py</a>.</p>
<p>If you want to integrate custom device commands with the Google Assistant using the gRPC interface,
instead use the <a class="reference external" href="https://developers.google.com/assistant/sdk/guides/service/python/">Google Assistant Service</a> directly. For an example, see <a class="reference external" href="https://github.com/googlesamples/assistant-sdk-python/blob/master/google-assistant-sdk/googlesamples/assistant/grpc/pushtotalk.py">this gRPC sample</a>.
Or instead of interacting with the Google Assistant, you can use <a class="reference internal" href="aiy.cloudspeech.html#module-aiy.cloudspeech" title="aiy.cloudspeech"><code class="xref py py-mod docutils literal notranslate"><span class="pre">aiy.cloudspeech</span></code></a>
to convert your voice commands into text that triggers your actions.</p>
<dl class="class">
<dt id="aiy.assistant.grpc.AssistantServiceClient">
<em class="property">class </em><code class="sig-prename descclassname">aiy.assistant.grpc.</code><code class="sig-name descname">AssistantServiceClient</code><span class="sig-paren">(</span><em class="sig-param">language_code='en-US'</em>, <em class="sig-param">volume_percentage=100</em><span class="sig-paren">)</span><a class="headerlink" href="#aiy.assistant.grpc.AssistantServiceClient" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></a></p>
<p>Provides a simplified interface for the <a class="reference external" href="https://developers.google.com/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#google.assistant.embedded.v1alpha2.EmbeddedAssistant">EmbeddedAssistant</a>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>language_code</strong> – Language expected from the user, in IETF BCP 47 syntax (default is “en-US”).
See the <a class="reference external" href="https://developers.google.com/assistant/sdk/reference/rpc/languages">list of supported languages</a>.</p></li>
<li><p><strong>volume_percentage</strong> – Volume level of the audio output. Valid values are 1 to 100
(corresponding to 1% to 100%).</p></li>
</ul>
</dd>
</dl>
<dl class="method">
<dt id="aiy.assistant.grpc.AssistantServiceClient.conversation">
<code class="sig-name descname">conversation</code><span class="sig-paren">(</span><em class="sig-param">deadline=185</em><span class="sig-paren">)</span><a class="headerlink" href="#aiy.assistant.grpc.AssistantServiceClient.conversation" title="Permalink to this definition">¶</a></dt>
<dd><p>Starts a conversation with the Google Assistant.</p>
<p>The device begins listening for your query or command and will wait indefinitely.
Once it completes a query/command, it returns to listening for another.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>deadline</strong> – The amount of time (in milliseconds) to wait for each gRPC request to
complete before terminating.</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="aiy.assistant.grpc.AssistantServiceClient.volume_percentage">
<em class="property">property </em><code class="sig-name descname">volume_percentage</code><a class="headerlink" href="#aiy.assistant.grpc.AssistantServiceClient.volume_percentage" title="Permalink to this definition">¶</a></dt>
<dd><p>Volume level of the audio output. Valid values are 1 to 100 (corresponding to 1% to 100%).</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="aiy.assistant.grpc.AssistantServiceClientWithLed">
<em class="property">class </em><code class="sig-prename descclassname">aiy.assistant.grpc.</code><code class="sig-name descname">AssistantServiceClientWithLed</code><span class="sig-paren">(</span><em class="sig-param">board</em>, <em class="sig-param">language_code='en-US'</em>, <em class="sig-param">volume_percentage=100</em><span class="sig-paren">)</span><a class="headerlink" href="#aiy.assistant.grpc.AssistantServiceClientWithLed" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#aiy.assistant.grpc.AssistantServiceClient" title="aiy.assistant.grpc.AssistantServiceClient"><code class="xref py py-class docutils literal notranslate"><span class="pre">aiy.assistant.grpc.AssistantServiceClient</span></code></a></p>
<p>Same as <a class="reference internal" href="#aiy.assistant.grpc.AssistantServiceClient" title="aiy.assistant.grpc.AssistantServiceClient"><code class="xref py py-class docutils literal notranslate"><span class="pre">AssistantServiceClient</span></code></a> but this also turns the
Voice Kit’s button LED on and off in response to the conversation.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>board</strong> – An instance of <a class="reference internal" href="aiy.board.html#aiy.board.Board" title="aiy.board.Board"><code class="xref py py-class docutils literal notranslate"><span class="pre">Board</span></code></a>.</p></li>
<li><p><strong>language_code</strong> – Language expected from the user, in IETF BCP 47 syntax (default is “en-US”).
See the <a class="reference external" href="https://developers.google.com/assistant/sdk/reference/rpc/languages">list of supported languages</a>.</p></li>
<li><p><strong>volume_percentage</strong> – Volume level of the audio output. Valid values are 1 to 100
(corresponding to 1% to 100%).</p></li>
</ul>
</dd>
</dl>
<dl class="method">
<dt id="aiy.assistant.grpc.AssistantServiceClientWithLed.conversation">
<code class="sig-name descname">conversation</code><span class="sig-paren">(</span><em class="sig-param">deadline=185</em><span class="sig-paren">)</span><a class="headerlink" href="#aiy.assistant.grpc.AssistantServiceClientWithLed.conversation" title="Permalink to this definition">¶</a></dt>
<dd><p>Starts a conversation with the Google Assistant.</p>
<p>The device begins listening for your query or command and will wait indefinitely.
Once it completes a query/command, it returns to listening for another.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>deadline</strong> – The amount of time (in milliseconds) to wait for each gRPC request to
complete before terminating.</p>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="aiy.assistant.grpc.AssistantServiceClientWithLed.volume_percentage">
<em class="property">property </em><code class="sig-name descname">volume_percentage</code><a class="headerlink" href="#aiy.assistant.grpc.AssistantServiceClientWithLed.volume_percentage" title="Permalink to this definition">¶</a></dt>
<dd><p>Volume level of the audio output. Valid values are 1 to 100 (corresponding to 1% to 100%).</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="module-aiy.assistant.library">
<span id="aiy-assistant-library"></span><h2>aiy.assistant.library<a class="headerlink" href="#module-aiy.assistant.library" title="Permalink to this headline">¶</a></h2>
<p>Facilitates access to the <a class="reference external" href="https://developers.google.com/assistant/sdk/guides/library/python/">Google Assistant Library</a>, which provides APIs to initiate
conversations with the Google Assistant and create custom device commands commands.</p>
<p>This includes a wrapper for the <code class="docutils literal notranslate"><span class="pre">Assistant</span></code> class only. You must import all other Google
Assistant classes directly from the <code> <a class="reference external" href="https://developers.google.com/assistant/sdk/reference/library/python/#">google.assistant.library</a></code> module
to handle each of the response events.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Hotword detection (such as “Okay Google”) is not supported with the Raspberry Pi Zero
(only with Raspberry Pi 2/3). If you’re using a Pi Zero, you must instead use the button or
another type of trigger to initiate a conversation with the Google Assistant.</p>
</div>
<dl class="class">
<dt id="aiy.assistant.library.Assistant">
<em class="property">class </em><code class="sig-prename descclassname">aiy.assistant.library.</code><code class="sig-name descname">Assistant</code><span class="sig-paren">(</span><em class="sig-param">credentials</em><span class="sig-paren">)</span><a class="headerlink" href="#aiy.assistant.library.Assistant" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code> <a class="reference external" href="https://developers.google.com/assistant/sdk/reference/library/python/#google.assistant.library.Assistant">google.assistant.library.Assistant</a></code></p>
<p>A wrapper for the <code> <a class="reference external" href="https://developers.google.com/assistant/sdk/reference/library/python/#Assistant">Assistant</a></code> class that handles
model and device registration based on the project name in your OAuth credentials
(<code class="docutils literal notranslate"><span class="pre">assistant.json</span></code>) file.</p>
<p>All the <code class="docutils literal notranslate"><span class="pre">Assistant</span></code> APIs are available through this class, such as
<code> <a class="reference external" href="https://developers.google.com/assistant/sdk/reference/library/python/#google.assistant.library.Assistant.start">start()</a></code> to start the
Assistant, and <code> <a class="reference external" href="https://developers.google.com/assistant/sdk/reference/library/python/#google.assistant.library.Assistant.start_conversation">start_conversation()</a></code> to start
a conversation, but they are not documented here. Instead refer to the
<a class="reference external" href="https://developers.google.com/assistant/sdk/reference/library/python/">Google Assistant Library for Python documentation</a>.</p>
<p>To get started, you must call <a class="reference internal" href="#aiy.assistant.auth_helpers.get_assistant_credentials" title="aiy.assistant.auth_helpers.get_assistant_credentials"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get_assistant_credentials()</span></code></a>
and pass the result to the <code class="docutils literal notranslate"><span class="pre">Assistant</span></code> constructor. For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">google.assistant.library.event</span> <span class="kn">import</span> <span class="n">EventType</span>
<span class="kn">from</span> <span class="nn">aiy.assistant</span> <span class="kn">import</span> <span class="n">auth_helpers</span>
<span class="kn">from</span> <span class="nn">aiy.assistant.library</span> <span class="kn">import</span> <span class="n">Assistant</span>

<span class="n">credentials</span> <span class="o">=</span> <span class="n">auth_helpers</span><span class="o">.</span><span class="n">get_assistant_credentials</span><span class="p">()</span>
<span class="k">with</span> <span class="n">Assistant</span><span class="p">(</span><span class="n">credentials</span><span class="p">)</span> <span class="k">as</span> <span class="n">assistant</span><span class="p">:</span>
    <span class="k">for</span> <span class="n">event</span> <span class="ow">in</span> <span class="n">assistant</span><span class="o">.</span><span class="n">start</span><span class="p">():</span>
        <span class="n">process_event</span><span class="p">(</span><span class="n">event</span><span class="p">)</span>
</pre></div>
</div>
<p>For more example code, see <a class="reference external" href="https://github.com/google/aiyprojects-raspbian/tree/aiyprojects/src/examples/voice/assistant_library_demo.py">src/examples/voice/assistant_library_demo.py</a>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>credentials</strong> – The Google OAuth2 credentials for the device. Get this from
<a class="reference internal" href="#aiy.assistant.auth_helpers.get_assistant_credentials" title="aiy.assistant.auth_helpers.get_assistant_credentials"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get_assistant_credentials()</span></code></a>.</p>
</dd>
</dl>
</dd></dl>

</div>
<div class="section" id="module-aiy.assistant.auth_helpers">
<span id="aiy-assistant-auth-helpers"></span><h2>aiy.assistant.auth_helpers<a class="headerlink" href="#module-aiy.assistant.auth_helpers" title="Permalink to this headline">¶</a></h2>
<p>Authentication helper for the Google Assistant API.</p>
<dl class="function">
<dt id="aiy.assistant.auth_helpers.get_assistant_credentials">
<code class="sig-prename descclassname">aiy.assistant.auth_helpers.</code><code class="sig-name descname">get_assistant_credentials</code><span class="sig-paren">(</span><em class="sig-param">credentials_file=None</em><span class="sig-paren">)</span><a class="headerlink" href="#aiy.assistant.auth_helpers.get_assistant_credentials" title="Permalink to this definition">¶</a></dt>
<dd><p>Retreives the OAuth credentials required to access the Google Assistant API.</p>
<p>If you’re using <a class="reference internal" href="#module-aiy.assistant.library" title="aiy.assistant.library"><code class="xref py py-mod docutils literal notranslate"><span class="pre">aiy.assistant.library</span></code></a>, you must call this function and pass the result
to the <a class="reference internal" href="#aiy.assistant.library.Assistant" title="aiy.assistant.library.Assistant"><code class="xref py py-class docutils literal notranslate"><span class="pre">Assistant</span></code></a> constructor.</p>
<p>If you’re using <a class="reference internal" href="#module-aiy.assistant.grpc" title="aiy.assistant.grpc"><code class="xref py py-mod docutils literal notranslate"><span class="pre">aiy.assistant.grpc</span></code></a>, you do not need this function because the
<a class="reference internal" href="#aiy.assistant.grpc.AssistantServiceClient" title="aiy.assistant.grpc.AssistantServiceClient"><code class="xref py py-class docutils literal notranslate"><span class="pre">AssistantServiceClient</span></code></a> calls this during initialization (using the
credentials file at <code class="docutils literal notranslate"><span class="pre">~/assistant.json</span></code>).</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>credentials_file</strong> – Absolute path to your JSON credentials file.
If None, it looks for the file at <code class="docutils literal notranslate"><span class="pre">~/assistant.json</span></code>.
To get a credentials file, <a class="reference external" href="https://aiyprojects.withgoogle.com/voice#google-assistant--get-credentials">follow these instructions</a>.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The device OAuth credentials, as a <code class="docutils literal notranslate"><span class="pre">google.oauth2.credentials.Credentials</span></code> object.</p>
</dd>
</dl>
</dd></dl>

</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="aiy.cloudspeech.html" class="btn btn-neutral float-right" title="aiy.cloudspeech" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="voice.html" class="btn btn-neutral float-left" title="Voice Kit overview" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2018, Google LLC

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>